package android.ly;

import android.app.Activity;
import android.content.Intent;
import android.ly.service.MyService;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

/**
 * service atcitvity
 * 
 * @author LiuY
 * 
 */
public class ServiceActivity extends Activity implements Button.OnClickListener {
	private Button startBtn;
	private Button endBtn;
	private Intent intent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.service);

		startBtn = (Button) findViewById(R.id.startBtn);
		endBtn = (Button) findViewById(R.id.endBtn);

		intent = new Intent();
		intent.setClass(this, MyService.class);

		startBtn.setOnClickListener(this);
		endBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.startBtn:
			startService(intent);
			break;
		case R.id.endBtn:
			stopService(intent);
			break;
		}
	}
}
